import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        active: 0, // tabbar选中
        logging: 0, // 登录状态
        user: {
            id: null,
            img: './static/images/userPhoto.jpg',
            name: '请登录',
            phone: null,
            password: null,
            order: null,
            address: null,
            coupon: null,
        },
        shopInfo: { img: '../../../static/images/head1.jpg' },
        buyList: [],
        countPrice: 0, //  总计
        merchantList: [] //商家列表
    },
    mutations: {

    },
    actions: {

    },
    // 过滤器 + compouted结合
    getters: {
        // 小结
        payBill(state) {
            return (state.countPrice + state.shopInfo.packPrice * state.buyList.length + state.shopInfo.sendPrice).toFixed(2)
        }
    }
})